﻿using Yxinmt.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Yxinmt.Components
{
    public class ScrollViewerComponent : BaseComponent, IComponent
    {
        Controls.ScrollViewer _ScrollViewer { get; set; }

        public ScrollViewerComponent(Dictionary<string, object> property, IWindow form)
        {
            _Property = property;
            Window = form;
            this.InitSet();

            this.ControlList = new List<IControl>();

            _ScrollViewer = new Controls.ScrollViewer(_Property, this);
            this.ControlList.Add(_ScrollViewer);

            LoadView();
        }

        public void LoadView(Dictionary<string, object> view = null)
        {
            if (view != null) _Property["properties"] = new List<Dictionary<string, object>>() { view };
            ComponentList = new List<IComponent>();
            SetView();

            var list = this.GetComponentsElements();
            if (list.Count == 1) _ScrollViewer.Add(list[0]);
        }
    }
}
